//
//  QiandaoViewController.m
//  GameBaby
//
//  Created by keyZhang on 14-1-22.
//  Copyright (c) 2014年 keyZhang. All rights reserved.
//

#import "QiandaoViewController.h"
#import "GameCenterViewController.h"
#import "CKCalendarView.h"


@interface QiandaoViewController ()
{
    CKCalendarView *calendar;
}

@end

@implementation QiandaoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        UILabel *t = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
        t.font = [UIFont systemFontOfSize:16];
        t.textColor = [UIColor blackColor];
        t.backgroundColor = [UIColor clearColor];
        t.textAlignment = UITextAlignmentCenter;
        t.text = @"每日签到";
        self.navigationItem.titleView = t;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
     calendar = [[CKCalendarView alloc] initWithStartDay:startMonday];
    [calendar setBackgroundColor:[UIColor colorWithWhite:0.000 alpha:0.500]];
    [calendar setDayOfWeekBottomColor:[UIColor clearColor] topColor:[UIColor clearColor]];
    [calendar setDateTextColor:[UIColor whiteColor]];
    [calendar setDayOfWeekTextColor:[UIColor whiteColor]];
    [calendar setButtonColor:[UIColor whiteColor]];
    [calendar setDateBackgroundColor:[UIColor clearColor]];
    [calendar setDateBorderColor:[UIColor clearColor]];
    [calendar setInnerBorderColor:[UIColor clearColor]];
    
    calendar.delegate = self;


    calendar.frame = CGRectMake(0, 90, 320, 70);
    [self.view addSubview:calendar];
    
    self.headImg.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self.headImg addGestureRecognizer:tap];
    
}

- (void)tapAction:(UITapGestureRecognizer *)tp
{
    if (calendar.bottom == self.view.bottom + 10) {
        [UIView animateWithDuration:0.35 animations:^{
            calendar.top = self.view.bottom - 40;
        }];
    }else
    {
        GameCenterViewController *gameCenterVC = [[GameCenterViewController alloc] init];
        gameCenterVC.gameXqUrl = @"http://m.a.ewoka.com/html/arclist/wjmt";
        [self.navigationController pushViewController:gameCenterVC animated:YES];
    }
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)calendar:(CKCalendarView *)calendar didSelectDate:(NSDate *)date
{
    [UIView animateWithDuration:0.35 animations:^{
        if (self.headImg.right == 0) {
            self.headImg.left = 0;
        }else
        {
            self.headImg.right = 0;
        }
    }];
    
//    self.headImg.left = 0;
}


@end
